package com.itheima.service.impl;

import com.itheima.dao.BlogGetAllDao;
import com.itheima.pojo.Blog;
import com.itheima.service.getAllBlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class getAllBlogServiceImpl implements getAllBlogService {

    @Autowired
    private BlogGetAllDao blogGetAllDao;

    public List<Blog> getAll() {
        //根据条件查询
        Example example = new Example(Blog.class);
        Example.Criteria criteria = example.createCriteria();
        //状态为1的可以查询
        criteria.andEqualTo("status", 1);
        List<Blog> blogList = blogGetAllDao.selectByExample(example);
        return blogList;
    }
}